home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / lt_showwindow.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  3KB  |  125 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #include "Assert.h"
  15.  
  16. /****** gtlayout.library/LT_ShowWindow ******************************************
  17. *
  18. *   NAME
  19. *    LT_ShowWindow -- Make a window visible
  20. *
  21. *   SYNOPSIS
  22. *    LT_ShowWindow(Handle,Activate);
  23. *                    A0      A1
  24. *
  25. *    VOID LT_ShowWindow(LayoutHandle *,BOOL);
  26. *
  27. *   FUNCTION
  28. *    The window attached to a LayoutHandle is made visible, this
  29. *    involves bringing it to the front, bringing the screen to
  30. *    the front the window resides on, unzooming the window and
  31. *    also moving the visible part of an autoscrolling screen.
  32. *
  33. *   INPUTS
  34. *    Window - Pointer to Window structure.
  35. *
  36. *    Activate - If TRUE the window will be activated as soon
  37. *        as it has been brought to the front.
  38. *
  39. *   RESULT
  40. *    none
  41. *
  42. *   NOTES
  43. *    The arguments are passed in A0 and A1, this is *not* a
  44. *    typo.
  45. *
  46. *   BUGS
  47. *    In revisions earlier than v21 this routine consistently
  48. *    failed to reliably unzip a window in zoomed state. This
  49. *    could cause the calling application to wait for about
  50. *    five seconds before continuing execution.
  51. *
  52. *   SEE ALSO
  53. *    intuition.library/MoveScreen
  54. *    intuition.library/ScreenPosition
  55. *    intuition.library/ZipWindow
  56. *
  57. ******************************************************************************
  58. *
  59. */
  60.  
  61. VOID LIBENT
  62. LT_ShowWindow(REG(a0) LayoutHandle *handle,REG(a1) BOOL activate)
  63. {
  64.     if(handle)
  65.     {
  66.         struct Window *window;
  67.         ULONG flags,mask;
  68.  
  69.         window = handle->Window;
  70.         flags = NULL;
  71.         mask = NULL;
  72.  
  73.         WindowToFront(window);
  74.  
  75.         if(activate)
  76.         {
  77.                 // activate the window
  78.  
  79.             ActivateWindow(window);
  80.  
  81.                 // wait for the window to become active
  82.  
  83.             flags |= WFLG_WINDOWACTIVE;
  84.             mask |= WFLG_WINDOWACTIVE;
  85.         }
  86.  
  87.         ScreenToFront(window->WScreen);
  88.  
  89.         if(!handle->ResizeObject && (handle->Window->Flags & (WFLG_HASZOOM | WFLG_ZOOMED)) == (WFLG_HASZOOM | WFLG_ZOOMED))
  90.         {
  91.                 // make the window full-sized
  92.  
  93.             ZipWindow(window);
  94.  
  95.                 // wait for the zoom bit to get cleared
  96.  
  97.             flags &= ~WFLG_ZOOMED;
  98.             mask |= WFLG_ZOOMED;
  99.         }
  100.  
  101.             // wait for the window to change state?
  102.  
  103.         if(mask)
  104.         {
  105.             LONG i;
  106.  
  107.                 // wait for the window to change state
  108.  
  109.             for(i = 0 ; i < 300 ; i++)
  110.             {
  111.                 if((handle->Window->Flags & mask) == flags)
  112.                     break;
  113.                 else
  114.                     WaitTOF();
  115.             }
  116.         }
  117.  
  118.             // make the window visible on the screen by
  119.             // scrolling it into view
  120.  
  121.         if(handle->MoveToWindow)
  122.             LTP_MoveToWindow(handle);
  123.     }
  124. }
  125.